#include "StdAfx.h"

#include <CGAL/Cartesian.h>
#include <CGAL/Homogeneous.h>
#include <CGAL/Filtered_kernel.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Filtered_kernel.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Cartesian_converter.h>


#include <CGAL/Point_2.h>
#include <CGAL/predicates_on_points_2.h>
#include <iostream>
#include <CGAL/Polygon_2.h>
#include <fstream>
using namespace std;
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Simple_cartesian<CGAL::Interval_nt_advanced> FK;
typedef CGAL::Simple_cartesian<CGAL::MP_Float> EK;
typedef CGAL::Cartesian_converter<K, EK> C2E;
typedef CGAL::Cartesian_converter<K, FK> C2F;


template<typename K>
struct My_Orientation_2 {
	typedef typename K::RT RT;
	typedef typename K::Point_2 Point_2;
	typedef K::Orientation result_type;

	result_type operator() (const Point_2& p, const Point_2& q, const Point_2& r) const
	{
		RT prx = p.x() - r.x();
		RT pry = p.y() - r.y();
		RT qrx = q.x() - r.x();
		RT qry = q.y() - r.y();

		return CGAL::sign(prx*qry - qrx*pry);
	}
};


typedef CGAL::Filtered_predicate<My_Orientation_2<EK>,
	My_Orientation_2<FK>, C2E, C2F> Orientation_2;

typedef CGAL::Homogeneous<long> Rep_class;
typedef CGAL::Point_2<Rep_class> Point;

void orientationt()
{
	Point p1(0, 0), p2(3, 17, 20), p3(9, 51, 10);
	switch (CGAL::orientation(p1,p2,p3))
	{
	case CGAL::LEFT_TURN:
		cout << "Left turn.";
		break;
	case CGAL::RIGHT_TURN:
		cout << "Right turn.";
		break;
	case CGAL::COLLINEAR:
		cout << "The three points lie on a line.";
		break;
	default:
		break;
	}
	cout << "\n";
}


typedef CGAL::Polygon_2<Rep_class> Polygon;
typedef Polygon::Edge_const_circulator Edge_circulator;


void Circulators()
{
	Polygon polygon;
	std::ifstream from("polygon.dat");
	CGAL::set_ascii_mode(from);
	from >> polygon;

	Edge_circulator start = polygon.edges_circulator();
	double perimeter = 0;
	if (start != 0)
	{
		Edge_circulator cur = start;

	}
}
